<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>京苏易购电子商务</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="adminlte/plugins/fontawesome-free/css/all.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="adminlte/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="adminlte/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="adminlte/css/adminlte.min.css">
    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet" href="../adminlte/css/SourceSans.css">
</head>


<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <a href="index3.html" class="brand-link">
            <img src="adminlte/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
                 style="opacity: .8">
            <span class="brand-text font-weight-light">帷易胜(JD)商品管理</span>
        </a>

        <!-- Sidebar -->
        <div class="sidebar">
            <div th:replace="common/sidebar :: common_side('./', 'item')"></div>
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-left">
                            <li class="breadcrumb-item"><a href="#">主页</a></li>
                            <li class="breadcrumb-item active">SKU商品列表</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <!--<div class="card-header">-->

                                <!--<button type="button" class="btn btn-primary" style="margin-right: 20px;" data-toggle="modal" data-target="#modal-default">-->
                                    <!--新 增-->
                                <!--</button>-->

                                <!--<button type="button" class="btn btn-primary" style="margin-right: 20px;" data-toggle="modal" data-target="#modal-default">-->
                                    <!--编 辑-->
                                <!--</button>-->

                                <!--<button type="button" class="btn btn-primary" style="margin-right: 20px;">-->
                                    <!--删 除-->
                                <!--</button>-->

                            <!--</div>-->
                            <!-- /.card-header -->
                            <div class="card-body">


                                <form class="form-horizontal">
                                    <div class="card-body">
                                        <div class="row">

                                            <div class="col-2">
                                                <input type="text" name="productcode" class="form-control" placeholder="产品编码">
                                            </div>


                                            <div class="col-2">
                                                <input type="text" name="name" class="form-control" placeholder="名称">
                                            </div>

                                            <div class="col-2">
                                                <input type="text" name="brandname" class="form-control" placeholder="品牌">
                                            </div>

                                            <div class="col-2">
                                                <input type="text" name="categoryname" class="form-control" placeholder="类目">
                                            </div>

                                            <div class="col-2">
                                                <select name="type"  class="form-control">
                                                    <option value=""> -商品来源- </option>
                                                    <option value="JD">京东</option>
                                                    <option value="MYMRO">固安捷</option>
                                                    <option value="JDMALL">京东工业品</option>
                                                </select>
                                            </div>

                                            <div class="col-1">
                                                <a href="#"  class="btn btn-primary queryBtn">搜 索</a>
                                            </div>


                                        </div>
                                    </div>
                                </form>



                                <table id="itemTable" class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <!--<th>任务ID</th>-->
                                        <th>SKU编码</th>
                                        <th>商品名称</th>
                                        <th>产品编码</th>
                                        <th>品牌</th>
                                        <th>类目</th>
                                        <th>来源</th>
                                        <th>URL</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </section>
        <!-- /.content -->
    </div>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="adminlte/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="adminlte/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="adminlte/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="adminlte/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="adminlte/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>

<!-- page script -->
<script>

    $(document).ready(function (){

        var table = $("#itemTable").DataTable({
            language: {
                url: 'i18n/Chinese.json'
            },

            "paging": true,
            "lengthChange": true,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "responsive": true,

            serverSide: true,
            "ajax": {
                "url": "item/query",
                "data": function ( d ) {
                    var values = $("form.form-horizontal").serializeArray();

                    var data = {};
                    $.each(values, function (index, item) {
                        data[item.name] = item.value;
                    });

                    return $.extend( {}, d, data);
                }
            },

            columns: [
                {
                    data : null,
                    bSortable : false,
                    width : "30px",
                    "orderable": false,
                    render : function(data, type, row, meta) {
                        // 顯示行號
                        var startIndex = meta.settings._iDisplayStart;
                        return startIndex + meta.row + 1;
                    }
                },

                /**
                 * brand: "得力（deli）"
                 brandname: "得力（deli）"
                 category: "文件管理"
                 categorydesc: "电脑、办公|文具|文件管理"
                 categoryname: "文件管理"
                 code: "100000115712"
                 name: "得力(deli)透气双层柔质收纳袋 布质A4拉链文件袋 单只深蓝 5841"
                 own: "Y"
                 picnum: 0
                 price: 8.8
                 productcode: "100000115712"
                 productname: "得力(deli)透气双层柔质收纳袋 布质A4拉链文件袋 单只深蓝 5841"
                 shop: "得力京东自营官方旗舰店"
                 stock: null
                 subname: null
                 type: "JD"
                 url: "https://item.jd.com/100000115712.html"
                 zt: "Y"
                 */

                {"data": "code", "width": "100px"},
                {"data": "name", "width": "200px"},
                {"data": "productcode", "width": "100px"},
                {"data": "brandname", "width": "120px"},
                {"data": "categoryname", "width": "120px"},
                {"data": "type", "width": "50px"},

                {"data": "url", "width": "200px",
                    render: function(data, type, row, meta) {
                        var html = [];
                        html.push('<a href="'+ data +'" target="_blank" >'+ data +'</a>');
                        return html.join('');
                    }
                },
            ]
        });

        $("a.queryBtn").click(function(){
            table.ajax.reload();
        });

    });
</script>
</body>
</html>
